package core.heuristic;

import core.course.Course;
import core.course.TimeTable;
import core.interfaces.IState;

public class NormalHeuristic extends HeuristicBase
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7626382795987580352L;

	@Override
	public Double getValue(IState<TimeTable> examinee)
	{
		TimeTable timeTable = examinee.getState();
		double score = 0.0;
		
		double fairFactor = fair(timeTable);
		double spacesFactor = spaces(timeTable) / 20;
		double collisionFactor = collision(timeTable);
		if (collisionFactor < 0)
		{
			//there are collisions
			score = collisionFactor;
		}
		else
		{
			//no collisions
			int relFactor = 0;
			for (Course course : timeTable)
			{
				if(isCourseRelevant(timeTable, course))
				{
					++relFactor;					
				}
			}
			relFactor = (relFactor * relFactor);
				
			score = relFactor * fairFactor * spacesFactor;
		}
		
		return score;
	}
	
	@Override
	public String toString()
	{
		return NormalHeuristic.class.getSimpleName();
	}

}
